package nio;

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

public class FileLockDemo5 {

	public static void main(String[] args) throws Exception {
		RandomAccessFile random = new RandomAccessFile("f1.txt", "rw");
		FileChannel channel = random.getChannel();
		FileLock lock = channel.lock(0, channel.size(), true);
		Thread.sleep(9000);
		lock.release();
	}

}
